<template>
<div class="container">
<Module1></Module1>
<Module1></Module1>

<p>当前父组件计数：{{ count }}</p>
<Module2 v-if="isExist" @updateCount="updateCount"></Module2>
<button @click="isExist = !isExist">切换</button>
</div>
</template>

<script setup>
import {ref} from 'vue'
import Module1 from './module1.vue';
import Module2 from './module2.vue';

const isExist = ref(false)

const count = ref(0)
const updateCount = (newCount) => {
  count.value = newCount; // 更新 count
};
</script>

<style scoped>
.container {
    text-align: center;
    margin-top: 50px;
    background-color: rgb(187, 187, 187);
    border-radius: 15px;
    padding: 10px;
    margin: 20px;
}
</style>